<template>
  <div class="dashboard-container">
    <el-row :gutter="24">
      <el-col
        :span="6"
        style="margin-bottom: 20px"
        v-for="(exam, index) in examList"
        :key="index"
      >
        <el-card class="pre-exam">
          <div slot="header" class="clearfix">
            <span>{{ exam.title }}</span>
            <el-button
              @click="toExam(exam.id)"
              style="float: right; padding: 3px 0"
              type="text"
              >去考试</el-button
            >
          </div>
          <div><strong>考试名称：</strong>{{ exam.title }}</div>
          <div><strong>考试时长：</strong>{{ exam.totalTime }}分钟</div>
          <div><strong>试卷总分：</strong>{{ exam.totalScore }}分</div>
          <div><strong>及格分数：</strong>{{ exam.qualifyScore }}分</div>
          <div><strong>考试描述：</strong>{{ exam.content }}</div>
          <div><strong>开放类型：</strong> {{ exam.openType }}</div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { myExams } from "@/api/exam";
export default {
  data() {
    return {
      examList: [],
    };
  },
  name: "Dashboard",
  computed: {
    ...mapGetters(["name"]),
  },
  methods: {
    toExam(examId) {
      this.$router.push({ path: "/exam/preview", query: { examId: examId } });
    },
  },
  created() {
    myExams().then((res) => {
      this.examList = res.data;
      console.log(this.examList);
    });
  },
};
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
